//
//  CustomerServiceViewController.m
//  PlayBall
//
//  Created by My Mac JiangDuoDuo on 14-8-8.
//
//

#import "JddCustomerServiceViewController.h"
#import "HUD.h"

@interface JddCustomerServiceViewController ()
{
    IBOutlet UIWebView *_adWebView;
}
@end

@implementation JddCustomerServiceViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
        UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];
        customLab.backgroundColor = [UIColor clearColor];
        [customLab setText:@"在线客服"];
        customLab.textAlignment = NSTextAlignmentCenter;

        [customLab setTextColor:[UIColor whiteColor]];
        customLab.font = [UIFont systemFontOfSize:19];
        self.navigationItem.titleView = customLab;
        
//        //self.navigationItem.hidesBackButton = YES;
        if(self.webOrLocalUrl)
    {
//        NSLog(@"url=%@",self.webUrlString);
        [_adWebView loadRequest:[NSURLRequest requestWithURL:self.webOrLocalUrl]];
    }
    else
    {
        if(! [[self.webUrlString substringToIndex:4] isEqualToString:@"http"])
        {
            self.webUrlString = [NSString stringWithFormat:@"http://%@",self.webUrlString];
        }
        self.title = self.pageTitle;
        NSURL *adUrl = [NSURL URLWithString:self.webUrlString];
//        NSLog(@"url=%@",self.webUrlString);
        [_adWebView loadRequest:[NSURLRequest requestWithURL:adUrl]];
    }

}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [MobClick beginLogPageView:@"CustomerService"];
    
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [MobClick endLogPageView:@"CustomerService"];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark UIWebViewDelegate

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    [HUD showUIBlockingIndicator];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [HUD hideUIBlockingIndicator];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    [HUD hideUIBlockingIndicator];
}

@end
